//
//  CertUtil.h
//  TestProject
//
//  Created by 毕武侠 on 2022/2/7.
//  Copyright © 2022 zhulong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CertTLV.h"
#import "CertExtension.h"
#import "CertPublicKeyInfo.h"

NS_ASSUME_NONNULL_BEGIN


// X509 扩展
@interface X509Extension : NSObject

@property (nonatomic, strong) NSString *oid;                    // oid
@property (nonatomic, assign) BOOL      critical;               // 默认False
@property (nonatomic, strong) NSString *value;                  // value

@end


// 证书Certificate结构体
@interface Certificate : NSObject

@property (nonatomic, strong) NSString *version;                                // 版本
@property (nonatomic, strong) NSString *serialNumber;                           // 证书序列号
@property (nonatomic, strong) NSArray<NSString *> *signature;                   // 算法
@property (nonatomic, strong) NSArray<NSArray<NSString *> *> *issuer;           // 颁发者
@property (nonatomic, strong) NSString *notBefore;                              // 开始时间
@property (nonatomic, strong) NSString *notAfter;                               // 结束时间
@property (nonatomic, strong) NSArray<NSArray<NSString *> *> *subject;          // 主题
@property (nonatomic, strong) CertPublicKeyInfo  *publicKeyInfo;                // 主题公钥算法

@property (nonatomic, strong) NSString *issuerUniqueIdentifier;                 // 颁发者唯一身份信息（可选项）
@property (nonatomic, strong) NSString *subjectUniqueIdentifier;                // 主题唯一身份信息（可选项）

@property (nonatomic, strong) NSArray<CertExtension *> *extensions;             // 扩展项（可选项）

@end

// X509结构
@interface X509Cert : NSObject

@property (nonatomic, strong) Certificate *certficate;                     // 证书详情
@property (nonatomic, strong) NSArray<NSString *> *signatureAlgorithm;     // 对证书进行签名所用的算法
@property (nonatomic, strong) NSString    *certficateSignature;            // 对证书签名后得到的 数字签名

- (instancetype)initWithBase64:(NSString *)data;

- (void)printCert;

@end

NS_ASSUME_NONNULL_END
